package com.yunkecn.redispubsub;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class RegisterController {

    @Autowired
    RedisTemplate redisTemplate;

    @RequestMapping(value = "reg")
    public String register(String name, String phone) {

        System.out.println(Thread.currentThread());

        RegisterMessage message = new RegisterMessage();
        message.setName(name);
        message.setPhone(phone);

        redisTemplate.convertAndSend("register", message);
        return "success";
    }
}
